package com.neusoft.yuejian_01.activity;

import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;

import com.neusoft.yuejian_01.R;
import com.neusoft.yuejian_01.adapter.VideoAdapter;
import com.neusoft.yuejian_01.base.BaseActivity;
import com.neusoft.yuejian_01.javabean.ClubVideoBean;
import com.neusoft.yuejian_01.listener.RetrofitListener;
import com.neusoft.yuejian_01.model.ClubModel;

import java.util.List;


public class VideoActivity extends BaseActivity implements RetrofitListener {
    private RecyclerView recyclerView;
    private VideoAdapter adapter;
    public TextView clubtitleView;
    private ImageButton button_back;//返回按钮
    private int c_id;

     protected void initView() {
         setContentView(R.layout.activity_video);
        recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
        button_back = (ImageButton) findViewById(R.id.button_back);
        clubtitleView = (TextView) findViewById(R.id.club_title);
    }
     protected void initEvents() {
        button_back.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
     protected void initData() {
        c_id = getIntent().getIntExtra("c_id",-1);
        String c_name = getIntent().getStringExtra("c_name");
        clubtitleView.setText(c_name);
        ClubModel clubModel = new ClubModel();
        clubModel.videolist(String.valueOf(c_id),this);
    }
    @Override
    public void onSuccess(Object object, int flag) {
        List<ClubVideoBean> clubVideoBean   = (List<ClubVideoBean>)object;
        adapter = new VideoAdapter(VideoActivity.this, clubVideoBean);
        LinearLayoutManager layoutManager = new LinearLayoutManager(VideoActivity.this);
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(layoutManager);
        recyclerView.setAdapter(adapter);
        recyclerView.setItemAnimator(new DefaultItemAnimator());
    }

    @Override
    public void onFail() {
        Toast.makeText(this,"fail",Toast.LENGTH_LONG).show();
    }

}
